/*
 * @Description: 导入所有的包文件
 * @Author: Cary
 * @Date: 2019-11-16 10:58:56
 * @FilePath: \excel-to-jsone:\work\node-project\cc-tools\src\index.js
 */

 // https://webpack.js.org/guides/dependency-management/#requirecontext
const modulesFiles = require.context('../packages', false, /\.js$/)

// you do not need `import app from './modules/app'`
// it will auto require all vuex module from modules file
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  // set './app.js' => 'app'
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {})

export default modules
